package com.ht.medicaltreatment.adapter

import android.widget.CheckBox
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.ht.medicaltreatment.R
import com.ht.medicaltreatment.bean.BorrowQueryPage

class BorrowQueryAdapter(sign:String):BaseQuickAdapter<BorrowQueryPage,BaseViewHolder>(R.layout.item_inventory_query_layout) {
    private var sign: String = sign

    override fun convert(holder: BaseViewHolder, item: BorrowQueryPage) {
        holder.setText(R.id.tvCode,"${getItemPosition(item)+1}")
        holder.setText(R.id.tvBoxName,item.name)
        val cbAll = holder.getView<CheckBox>(R.id.cbAll)
        if(sign == "0"){
            //样本
            if(item.status == 1){
                holder.setText(R.id.tvType,"正常")
                cbAll.isEnabled = true
            }else{
                holder.setText(R.id.tvType,"借出")
                cbAll.isEnabled = false
            }
        }else{
            //样本盒
            if(item.status == 0){
                holder.setText(R.id.tvType,"正常")
                cbAll.isEnabled = true
            }else{
                holder.setText(R.id.tvType,"借出")
                cbAll.isEnabled = false
            }
        }
        cbAll.isChecked = item.isChecked
    }
}